<!DOCTYPE html>
<html>
<!--
Copyright The Closure Library Authors. All Rights Reserved.

Use of this source code is governed by the Apache License, Version 2.0.
See the COPYING file for details.
-->
<head>
  <title>goog.ui.Slider</title>
  <meta charset="utf-8">
  <script src="../base.js"></script>
  <script>
    goog.require('goog.dom');
    goog.require('goog.ui.Component');
    goog.require('goog.ui.Slider');
  </script>
  <link rel="stylesheet" href="css/demo.css">
  <style>
    .goog-slider-vertical,
    .goog-slider-horizontal {
      background-color: ThreeDFace;
      position: relative;
      overflow: hidden;
    }
    .goog-slider-thumb {
      position: absolute;
      background-color: ThreeDShadow;
      overflow: hidden;
    }

    .goog-slider-vertical .goog-slider-thumb {
      left: 0;
      height: 20px;
      width: 100%;
    }

    .goog-slider-horizontal .goog-slider-thumb {
      top: 0;
      width: 20px;
      height: 100%;
    }
    .goog-slider-disabled {
      background-color: lightgray
    }
    #s-h {
      margin-bottom: 2em;
    }
    strong {
      display: block;
      margin-bottom: 3px;
    }
  </style>
</head>
<body>
  <h1>goog.ui.Slider</h1>

  <div id="s-h">
    <strong>Horizontal Slider</strong>
    <div id="s1" class="goog-slider" style="width: 200px; height: 20px">
      <!-- this line is here just to show that custom content can be added -->
      <div style="position:absolute;width:100%;top:9px;border:1px inset white;
                  overflow:hidden;height:0"></div>
      <div class="goog-slider-thumb"></div>
    </div>
    <input type="checkbox" onclick="s.setMoveToPointEnabled(this.checked)">
    MoveToPointEnabled
    <input type="checkbox" onclick="s.setEnabled(this.checked)" checked>
    Enable
    <br>
    <input type="text" value="0" id="out1" style="margin-left: 0px">
    <input type="button" value="Set Value" onclick="setSliderValue(s, 'out1')">
  </div>

  <div id="s-v">
    <strong>Vertical Slider, inserted w/ script</strong>
    <label id="s2-label">
      <input type="checkbox" onclick="s2.setMoveToPointEnabled(this.checked)">
      MoveToPointEnabled
    </label>
    <input type="checkbox" onclick="s2.setEnabled(this.checked)" checked>
    Enable
    <br>
    <input type="text" value="0" id="out2" style="margin-left: 0px">
    <input type="button" value="Set Value" onclick="setSliderValue(s2, 'out2')">
  </div>
  <script>

  var el = document.getElementById('s1');
  var s = new goog.ui.Slider;
  s.decorate(el);
  s.addEventListener(goog.ui.Component.EventType.CHANGE, function() {
    document.getElementById('out1').value = s.getValue();
  });


  var s2 = new goog.ui.Slider;
  s2.setOrientation(goog.ui.Slider.Orientation.VERTICAL);
  s2.createDom();
  var el = s2.getElement();
  el.style.width = '20px';
  el.style.height = '200px';
  s2.render(document.body);
  s2.setStep(null);
  s2.addEventListener(goog.ui.Component.EventType.CHANGE, function() {
    document.getElementById('out2').value = s2.getValue();
  });

  var label = document.getElementById('s2-label');
  label.parentNode.insertBefore(el, label);

  function toggleSliderEnable(button, slider) {
    var buttonValue = slider.isEnabled() ? 'Enable Slider' : 'Disable Slider';
    button.value = buttonValue;
    slider.setEnabled(!slider.isEnabled());
  }

  function setSliderValue(slider, textId) {
    if (document.getElementById(textId)) {
      var value = document.getElementById(textId).value;
      window.console.log(value);
      slider.setValue(new Number(value));
    }
  }

  </script>
</body>
</html>
